home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / amiga / convrtrs / fixiff.lha / FixIFF / Source / FixIff.c next >
Encoding:
C/C++ Source or Header  |  1993-01-14  |  1.9 KB  |  101 lines

  1. #include "Include_FixIff.h"
  2. #include "prototypes.h"
  3.  
  4. VOID main(argc, argv)
  5. int argc;
  6. register UBYTE **argv;
  7. {
  8.     register int filiere;
  9.     register USHORT i, j;
  10.  
  11.     struct BitMapHeader    *BMHD;
  12.     struct CAMGHeader        *CAMG;
  13.     UBYTE buf[2000];
  14.     USHORT horiz, vert;
  15.  
  16.     if (argc < 2)
  17.         printf("FixIff v1.0  (c) 1993 Christian Warren\nUsage : FixIff [-L -H -I -N] <Ifffile>\n-L = LORES   -H = HIRES   -I = INTERLACE   -N = NOT INTERLACE\n\n");
  18.     else
  19.     {
  20.         horiz = vert = 0;
  21.  
  22.         for (i = 1; argv[i][0] == '-'; i++)
  23.         {
  24.             switch(argv[i][1])
  25.             {
  26.                 case 'l':
  27.                 case 'L':
  28.                     horiz = LO;
  29.                     break;
  30.                 case 'h':
  31.                 case 'H':
  32.                     horiz = HI;
  33.                     break;
  34.                 case 'i':
  35.                 case 'I':
  36.                     vert = INT;
  37.                     break;
  38.                 case 'n':
  39.                 case 'N':
  40.                     vert = NONINT;
  41.                     break;
  42.             }
  43.         }
  44.  
  45.         printf("%s ", argv[i]);
  46.         
  47.         if ((filiere = open(argv[i], O_RDWR, 0)) != -1)
  48.         {
  49.             read(filiere, buf, sizeof(buf));
  50.  
  51.             j = 0;
  52.             while (j < 2000)
  53.             {
  54.                 if (!strnicmp(&buf[j], "BMHD", 4))
  55.                 {
  56.                     j += 4;
  57.                     BMHD = (struct BitMapHeader *) &buf[j];
  58.  
  59.                     BMHD->pageWidth = ((BMHD->w <= 400) || (BMHD->nPlanes == 6))
  60.                                             ? 320 : 640;
  61.                     BMHD->pageHeight = (BMHD->h > 300) ? 400 : 200;
  62.  
  63.                     if (horiz)
  64.                         BMHD->pageWidth =  (horiz == LO) ? 320 : 640;
  65.                     if (vert)
  66.                         BMHD->pageHeight = (vert == INT) ? 400 : 200;
  67.  
  68.                     printf("( %d * %d * %d ) Screen ( %d * %d ) "
  69.                                 , BMHD->w, BMHD->h, BMHD->nPlanes
  70.                                 , BMHD->pageWidth, BMHD->pageHeight);
  71.                 }
  72.                 j++;
  73.             }
  74.  
  75.             j = 0;
  76.             while (j < 2000)
  77.             {
  78.                 if (!strnicmp(&buf[j], "CAMG", 4))
  79.                 {
  80.                     j += 4;
  81.                     CAMG = (struct CAMGHeader *) &buf[j];
  82.  
  83.                     CAMG->ViewMode = SPRITES + ((BMHD->pageWidth    == 640) << 15)
  84.                                                     + ((BMHD->pageHeight    == 400) << 2)
  85.                                                     + ((BMHD->nPlanes     == 6)    << 11);
  86.                 }
  87.                 j++;
  88.             }
  89.  
  90.             lseek(filiere, 0, 0);
  91.             write(filiere, buf, sizeof(buf));
  92.  
  93.             close(filiere);
  94.         }
  95.         else
  96.             printf("I can't found the file!\n");
  97.     }
  98.     printf("\n");
  99.     exit(0);
  100. }
  101.